﻿Imports Mysoft.Map.Application
Imports MySoft.Map.Service
Imports MySoft.Map.Application.Security

Partial Public Class LogonModeUI
    Inherits Mysoft.Map.Application.Security.AppPage

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        '如果用户没有设置集成登录的权限，提示“无访问权限”
        If Not MySoft.Map.Application.Security.User.CheckUserRight(Session("UserGUID"), "00000114", "11") Then
            Throw New Exception("无功能权限")
        End If
        '从Web.config中读取LOGON_MODE，集成方式
        Dim sLOGON_MODE As String = WebConfig.ReadAppSettings("LOGON_MODE")
        Select Case sLOGON_MODE.ToLower()
            Case "AD".ToLower()
                appForm_AD.Checked = True
                Exit Select
            Case "Cookie".ToLower()
                appForm_Cookie.Checked = True
                Exit Select
            Case Else
                appForm_Form.Checked = True
                Exit Select
        End Select
        Dim sDomainName As String = WebConfig.ReadAppSettings("DomainName")
        Dim sPrivateKey As String = WebConfig.ReadAppSettings("PrivateKey")
        Dim sPublicKey As String = WebConfig.ReadAppSettings("PublicKey")


        'sDomainName = Mysoft.Map.Utility.General.GetDomain(Request.Url.ToString())
        txtDomainName.Value = sDomainName

        If sPublicKey = "" Then '若未定义公钥，则取默认公钥显示
            sPublicKey = Mysoft.Map.Security.RSAUtil.publicKey
            sPrivateKey = Mysoft.Map.Security.RSAUtil.privateKey
        End If

        txtPrivateKey.Value = sPrivateKey
        txtPublicKey.Value = sPublicKey

        Dim sIIS_PASS As String = WebConfig.ReadAppSettings("IIS_PASS")
        If sIIS_PASS = "1" Then
            appForm_IIS_PASS1.Checked = True
        Else
            appForm_IIS_PASS0.Checked = True
        End If

        '当前用户代码、密码，DSS站点
        txtUserCode.Value = Session("UserCode")
        txtPassWord.Value = Session("PassWord")
        txtDSSSite.Value = MySite.GetSitePathByName("MysoftERP_决策支持系统")

        If VerifyApplication.CheckLicenseObject("0302", "系统") OrElse VerifyApplication.CheckLicenseObject("0303", "系统") Then
            txtHasDSS.Value = "1"
        End If

    End Sub

End Class